package com.activiti.advance;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

/**
 * 完成个人任务，以此验证流程挂起与激活功能
 *
 * @author ldanniel
 */
public class CompleteOwnerTask {
    public static void main(String[] args) {
        //创建
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        TaskService taskService = processEngine.getTaskService();
        //通过任务服务接口获取，参数：流程id,负责人
        Task task = taskService.createTaskQuery()
                .processInstanceId("2501")
                .taskAssignee("zhangsan")
                .singleResult();
        System.out.println("流程id = " + task.getProcessInstanceId());
        System.out.println("任务id = " + task.getId());
        System.out.println("负责人 = " + task.getAssignee());
        System.out.println("任务名称 = " + task.getName());
        //根据任务id完成任务
        taskService.complete(task.getId());
        System.out.println("执行任务完成");

    }
}
